/*
 * @Author: 朱自强
 * @Date: 2024-03-08 17:31:55
 * @LastEditors: 朱自强
 * @LastEditTime: 2024-03-08 17:44:56
 * @FilePath: \A-LOT-OF-TEST-VUE3\src\plugins\setupConfigJson.ts
 * @Description:
 *
 * Copyright (c) 2024 by 朱自强, All Rights Reserved.
 */
import type { Config } from '@/types/config'
export default function readConfigJson(): Promise<Config> {
  return new Promise((resolve, reject) => {
    const xhr = new XMLHttpRequest()
    let config: Config
    xhr.open('GET', '/config.json')
    xhr.onload = function () {
      if (xhr.status === 200) {
        config = JSON.parse(xhr.response)
        resolve(config)
      } else {
        reject(config)
      }
    }
    xhr.send()
  })
}
